home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / uip / snd / s_main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-11  |  4.9 KB  |  168 lines

  1. /*
  2.    interactive mail-sender
  3.  
  4.    ??? ?? ?. ?????          Probably originated in Illinois, but it's
  5.                 like Daniel Boone's knife, with the blade
  6.                 replaced 3 times & the handle 4.
  7.    Oct 80 S. Cracraft       Conversion from V6 to V7 and incorprate changes
  8.                 for all interaction done with MMDF, including
  9.                 *_address routines
  10.    Spr 81 D. Crocker        More cleanup; adding V6 compatability; signature;
  11.                 draft; forward inclusion mod; some help
  12.                 commands; better address parsing
  13.    Jul 81 D. Crocker        add quoting to name-parts of addresses, with
  14.                 special characters; allow comment fields to
  15.                 have special chars.
  16.                 minor diddling with fieldname displaying
  17.     Aug 81 D. Crocker       gather() needed to check characters from getchar
  18.     Sep 81 D. Crocker       have Bcc not printed, when there are no To addrs
  19.     Oct 81 D. Crocker       Make BCC say "(Private)" and disable To & CC,
  20.                 to prevent accidental replies.
  21.                 Make continuation  header lines begin with space,
  22.                 instead of name.
  23.     Nov 81 D. Crocker       save copy in ",sent", instead of ",send"
  24.                 input commands case-insensitive
  25.     Jan 82 D. Kingston        Modified to make use of the ",sent" file optional
  26.                 based on defining SENTFILE, also changed screen
  27.                 editor to Emacs.  (BRL 6.145)
  28.     Feb 82 D. Kingston        Users full name is now taken from /etc/passwd,
  29.                 Network name is placed in <> afterwords (BRL 6.152)
  30.     Mar 82 D. Kingston        Have send close file desc. 3-N before execing
  31.                 subshells or subprograms.
  32.     Apr 82 D. Kingston        Rearranged the invocation of submit.  Lossage:
  33.                 channel table fd's are still left open on execs
  34.     03/31/83  GWH        Split SEND into its component parts.
  35.  
  36.     06/30/83  GWH    Added numerous features to send. See comments in
  37.             "s_get.c", etal. Also added unique draft file naming
  38.             with the draft files' deletion at the end of the
  39.             session.
  40.  
  41.     01/29/86 TRT    Changed the input scheme so that the user is placed
  42.             directly into a visual editor, and is free to edit
  43.             both the headers and body.  Also removed the
  44.             following options:
  45.                 direct edit, header edit, input more body,
  46.                 delete body, visual edit (same as edit)
  47.             Threw in some assorted comments.
  48. */
  49.  
  50.  
  51. #include "./s.h"
  52.  
  53. extern int errno;
  54. extern char *compress ();
  55. extern char *index();
  56.  
  57. /* mmdf globals */
  58.  
  59. extern int  sentprotect;
  60. extern char *locname;
  61. extern char *delim1;
  62.  
  63. /* end of mmdf globals */
  64.  
  65. char hdrfmt[] = "%-10s%s\n";
  66. char    toname[] =  "To:  ";
  67. char    BCtoname[] = "[To]: ";   /* Bcc copy's To fieldname              */
  68. char    ccname[] =  "cc:  ";
  69. char    BCccname[] = "[cc]: ";   /* Bcc copy's CC fieldname              */
  70. char    subjname[] = "Subject:  ";
  71. char    fromname[] = "From:  ";
  72. char    datename[] = "Date:  ";
  73. char    bccname[] = "BCC:  ";
  74. char    shrtfmt[] = "%s%s\n";
  75.  
  76. jmp_buf savej;
  77.  
  78. int     drffd;                  /* handle on the draft file */
  79. int     tmpfd;
  80. int     nsent;
  81. int     badflg;              /* true if at least one bad address */
  82. int    (*orig) ();               /* to save old signal values */
  83.  
  84. char   *adrptr;                   /* field currently getting addresses  */
  85. char    bigbuf[BBSIZE],              /* buffer for text of msg */
  86.     signature[S_BSIZE],            /* hold the signature */
  87.     host[64],                 /* default hostname */
  88.     from[S_BSIZE],
  89.     to[S_BSIZE],          /* primary recipients                 */
  90.     bcc[S_BSIZE],         /* blind carbon copy addresses        */
  91.     cc[S_BSIZE],          /* secondary recipients               */
  92.     subject[S_BSIZE],
  93.     stdobuffer[BUFSIZ],
  94.     inclfile[FILNSIZE],
  95.     aliasfilename[128],
  96.     drffile[S_BSIZE],
  97.     tmpdrffile[S_BSIZE];
  98.     
  99. char    body,
  100.     lastsend,
  101.     aborted,
  102.     inrdwr,                   /* true if in a read or write */
  103.     toflag = TRUE,
  104.     ccflag= TRUE,
  105.     subjflag = TRUE;
  106.  
  107. /* Set the default user settable options */
  108.  
  109. char editor[128];
  110. char checker[128];
  111. char copyfile[128];
  112. char subargs[128];
  113. int wflag, cflag;
  114. int rflag;
  115. int qflag, pflag;
  116. struct header *headers = (struct header *)0;
  117.  
  118. /* */
  119.  
  120. main (argc, argv)
  121. int     argc;
  122. char   *argv[];
  123. {
  124.     extern sigtype  onint2 ();
  125.     int     retval;
  126.  
  127.     mmdf_init( argv[0] );
  128.  
  129.     setbuf (stdout, stdobuffer);
  130.  
  131.     if (setjmp(savej) != 0)
  132.     exit(9);
  133.  
  134.     orig = signal (SIGINT, onint2);
  135.  
  136.     if (!getuinfo ())
  137.     snd_abort ("Problem acquiring user information.\n");
  138.  
  139.     if (rp_isbad (retval = mm_init ()) || rp_isbad (retval = mm_sbinit ()))
  140.     snd_abort ("Problem with mail startup [%s].\n", rp_valstr (retval));
  141.  
  142.     arginit (argc, argv);
  143.  
  144.     if ((drffd = creat (drffile, sentprotect)) >= 0)
  145.     drclose ();
  146.     else                          /* can't get a clean drf            */
  147.     {
  148.     fprintf(stderr,"Can't open draft file '%s'\n", drffile);
  149.     fflush(stdout);
  150.     s_exit( NOTOK );
  151.     }
  152.  
  153.     if((tmpfd = creat(tmpdrffile, sentprotect)) >= 0)
  154.     close( tmpfd );
  155.     else
  156.     {
  157.     fprintf(stderr,"Can't open temporary draft file '%s'\n", tmpdrffile);
  158.     fflush(stdout);
  159.     s_exit( NOTOK );
  160.     }
  161.  
  162.     input ();
  163.  
  164.     mm_end (OK);
  165.     fflush (stdout);
  166.     s_exit (0);
  167. }
  168.